/**
 * 
 */
package com.rf.richfitwheel.admin.sys.controller;

import com.rf.richfitwheel.admin.contants.UrlConstant;
import com.rf.richfitwheel.admin.sys.model.SysLog;
import com.rf.richfitwheel.admin.sys.model.User;
import com.rf.richfitwheel.admin.sys.service.SysLogService;
import com.rf.richfitwheel.admin.sys.vo.UserVO;
import com.rf.richfitwheel.admin.utils.UserUtil;
import com.rf.richfitwheel.common.utils.PageUtils;
import com.rf.richfitwheel.common.utils.R;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hushouquan
 *
 */
@RestController
@RequestMapping(UrlConstant.WEB_ADMIN_URL+"/log")
public class SysLogController {
	
	private static Logger log = LoggerFactory.getLogger(SysLogController.class);
	
	@Autowired
	private SysLogService sysLogService;
	
	/**
	 * 日志查询
	 * @param page
	 * @param limit
	 * @param staff_name
	 * @param username
	 * @param user_ip
	 * @param oper_time_start
	 * @param oper_time_end
	 * @return
	 */
	@RequestMapping(value = "/list",method = RequestMethod.GET)
	@ResponseBody
	public R list(String page, String limit, String staff_name, String username, String user_ip, String oper_time_start, String oper_time_end) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("page", page);
		params.put("limit", limit);
		params.put("staff_name", staff_name);
		params.put("username", username);  
		params.put("user_ip", user_ip);  
		params.put("oper_time_start", oper_time_start);  
		params.put("oper_time_end", oper_time_end);  
		PageUtils pages = sysLogService.queryPage(params);
  	  	return  new R().put("page",pages);
	}
	
	/**
	 * 记录日志
	 * @param sysLog
	 */
	@RequestMapping(value = "/save",method = RequestMethod.POST)
	public void save(@RequestBody SysLog sysLog) {		
	
		UserVO userVO = UserUtil.getUser();
		//CouncilmbOrg org = (CouncilmbOrg)session.getAttribute(Constant.USER_ORG_SESSION);
		sysLogService.insertLog(sysLog);

	}
	
}
